﻿// Models/Components/BaseComponent.cs
using Newtonsoft.Json;

namespace AmisSdk.Models.Components
{
    public class TextInput : BaseComponent
    {
        public override string Type => "input-text";

        /// <summary>
        /// 数据字段名。
        /// </summary>
        [JsonProperty("name")]
        public string Name { get; set; }

        /// <summary>
        /// 控件标签。
        /// </summary>
        [JsonProperty("label")]
        public string Label { get; set; }

        /// <summary>
        /// 控件占位符。
        /// </summary>
        [JsonProperty("placeholder")]
        public string Placeholder { get; set; }

        /// <summary>
        /// 是否必填。
        /// </summary>
        [JsonProperty("required")]
        public bool Required { get; set; } = false;

        /// <summary>
        /// 默认值。
        /// </summary>
        [JsonProperty("value")]
        public string Value { get; set; }

        /// <summary>
        /// 验证规则。
        /// </summary>
        [JsonProperty("validation")]
        public Validation Validation { get; set; }  // 可选

        // 其他属性，如输入类型（email, number 等）
    }

    public class Validation
    {
        [JsonProperty("required")]
        public bool Required { get; set; } = false;

        [JsonProperty("minLength")]
        public int? MinLength { get; set; }

        [JsonProperty("maxLength")]
        public int? MaxLength { get; set; }

        [JsonProperty("pattern")]
        public string Pattern { get; set; }

        [JsonProperty("message")]
        public string Message { get; set; }
    }
}
